Ext.define('FM.controller.MainController', {
	extend : 'Ext.app.Controller',
	init : function() {
		console.log('The main controller was load');
	},
	/***************************************************************************
	 * 动态加载controller
	 * 
	 * @param name
	 *            controller全名数组/单一controller名称
	 * @param controller
	 *            加载controller的当前controller
	 * @returns {Boolean}成功：true；失败：false
	 */
	requireController : function(name, controller) {
		if (name instanceof Array) {
			var array = name;
			if (array.length > 0) {
				Ext.require(array, function() {
					for ( var i = 0; i < array.length; i++) {
						var lenssCon = controller.getController(array[i]);
						lenssCon.init(controller);
					}
				}, controller);
				return true;
			} else {
				return false;
			}
		} else {
			Ext.require(name, function() {
				var lenssCon = controller.getController(name);
				lenssCon.init(controller);
			}, controller);
			return true;
		}
	},
	showWindow : function(xtypename, id, title){
		var winId = "win_" + id;
		var win = Ext.getCmp(winId);
		if(Ext.isEmpty(win)){
			win = Ext.create('Ext.window.Window', {
				id : winId,
			    title: title,
			    //height: auto,
			    //width: auto,
			    layout: 'fit',
			    items: {
			        xtype: xtypename,
			    }
			});
			win.show();
		} else {
			win.show();
		}
	}
});